<!doctype html>
<html lang="en">
<head>
    <title>Code coverage report for src/views/modules/sys/role-add-or-update.vue</title>
    <meta charset="utf-8" />
    <link rel="stylesheet" href="..\..\..\..\prettify.css" />
    <link rel="stylesheet" href="..\..\..\..\base.css" />
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <style type='text/css'>
        .coverage-summary .sorter {
            background-image: url(..\..\..\..\sort-arrow-sprite.png);
        }
    </style>
</head>
<body>
<div class='wrapper'>
  <div class='pad1'>
    <h1>
      <a href="..\..\..\..\index.html">All files</a> / <a href="index.html">src/views/modules/sys</a> role-add-or-update.vue
    </h1>
    <div class='clearfix'>
      <div class='fl pad1y space-right2'>
        <span class="strong">0% </span>
        <span class="quiet">Statements</span>
        <span class='fraction'>0/51</span>
      </div>
      <div class='fl pad1y space-right2'>
        <span class="strong">0% </span>
        <span class="quiet">Branches</span>
        <span class='fraction'>0/32</span>
      </div>
      <div class='fl pad1y space-right2'>
        <span class="strong">0% </span>
        <span class="quiet">Functions</span>
        <span class='fraction'>0/19</span>
      </div>
      <div class='fl pad1y space-right2'>
        <span class="strong">0% </span>
        <span class="quiet">Lines</span>
        <span class='fraction'>0/38</span>
      </div>
    </div>
  </div>
  <div class='status-line low'></div>
<pre><table class="coverage">
<tr><td class="line-count quiet">1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124</td><td class="line-coverage quiet"><span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span></td><td class="text"><pre class="prettyprint lang-js">&lt;<span class="cstat-no" title="statement not covered" >t<span class="fstat-no" title="function not covered" >em</span>plate&gt;</span>
  &lt;el-dialog
    :title="!dataForm.id ? '新增' : '修改'"
<span class="cstat-no" title="statement not covered" >    :close-on-click-modal="false"</span>
    :visible.sync="visible"&gt;
    &lt;el-form :model="dataForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="dataFormSubmit()" label-width="80px"&gt;
      &lt;el-form-item label="角色名称" prop="roleName"&gt;
        &lt;el-i<span class="cstat-no" title="statement not covered" >nput v-model="dataF</span>orm.roleName" placeholder="角色名称"&gt;&lt;/el-input&gt;
      &lt;/el-form-item&gt;
<span class="cstat-no" title="statement not covered" >      &lt;el-form-item label="备注" prop="remark"&gt;</span>
        &lt;el-input<span class="fstat-no" title="function not covered" > v-mo</span>del="dataForm.remark" placeholder="备注"&gt;&lt;/el-input&gt;
<span class="cstat-no" title="statement not covered" >      &lt;/el-form-item&gt;</span>
      &lt;el-form-item size="mini" label="授权"&gt;
        &lt;el-tree
          :data="menuList"
          :props="menuListTreeProps"
          node-key="menuId"
          ref="menuListTree"
          :default-expand-all="true"
          show-checkbox&gt;
        &lt;/el-tree&gt;
      &lt;/el-form-item&gt;
    &lt;/el-form&gt;
    &lt;span slot="footer" class="dialog-footer"&gt;
      &lt;el-button @click="visible = false"&gt;取消&lt;/el-button&gt;
      &lt;el-button type="primary" @click="dataFormSubmit()"&gt;确定&lt;/el-button&gt;
    &lt;/span&gt;
  &lt;/el-dialog&gt;
&lt;/template&gt;
&nbsp;
&lt;script&gt;
  import { treeData<span class="fstat-no" title="function not covered" >Trans</span>late } from '@/utils'
  export default {<span class="cstat-no" title="statement not covered" ></span>
    data () {
<span class="cstat-no" title="statement not covered" >      return {</span>
<span class="cstat-no" title="statement not covered" >        visible: false,</span>
        menuList: [],
        menuListTreeProps: {
          label: 'name',
          chil<span class="fstat-no" title="function not covered" >dr</span>en: 'children'
        },<span class="cstat-no" title="statement not covered" ></span>
        dataForm: {
<span class="cstat-no" title="statement not covered" >          id: 0,</span>
          role<span class="fstat-no" title="function not covered" >Na</span>me: '',
<span class="cstat-no" title="statement not covered" >          remark: ''</span>
<span class="cstat-no" title="statement not covered" >        },<span class="fstat-no" title="function not covered" ></span></span>
        da<span class="cstat-no" title="statement not covered" >taRule: {</span>
<span class="cstat-no" title="statement not covered" >          roleName: [</span>
            { required: true, message: '角色名称不能为空', trigger: 'blur' }
          ]<span class="fstat-no" title="function not covered" ></span>
<span class="cstat-no" title="statement not covered" >        },</span>
        te<span class="cstat-no" title="statement not covered" >mpKey: -666666 // 临时key, 用于解决tree半选中状态项不能传给后台接口问题. # 待优化</span>
      }
    },
    methods: {
      init (id) {<span class="fstat-no" title="function not covered" ></span>
        this.dataForm.i<span class="cstat-no" title="statement not covered" >d = id || 0</span>
        this.$http({
          ur<span class="cstat-no" title="statement not covered" >l: this.$http.adornUrl('/sys/menu/list'),</span>
          meth<span class="cstat-no" title="statement not covered" >od: 'get',</span>
          para<span class="cstat-no" title="statement not covered" >ms: this.$http.adornParams()</span>
        }).then(({data})<span class="cstat-no" title="statement not covered" > =&gt; {</span>
          this<span class="cstat-no" title="statement not covered" >.menuList = treeDataTranslate(data, 'menuId')</span>
        }).then(<span class="cstat-no" title="statement not covered" >() =&gt; {</span>
          this.visible = true
          this<span class="cstat-no" title="statement not covered" >.$nextTick(() =&gt; {</span>
            this.$refs['dataForm'].resetFields()
            this.$refs.menuListTree.setCheckedKeys([])
          })
        }).then(() =&gt; {
          if (this.dataForm.id) {
            this.$http({
              url: this.$http.adornUrl(`/sys/role/info/${this.dataForm.id}`),
              method: 'get',<span class="fstat-no" title="function not covered" ></span>
              param<span class="cstat-no" title="statement not covered" >s: th</span>is.$http.adornParams()
            }).then(({data}) =&gt; {
<span class="cstat-no" title="statement not covered" >              if (data &amp;&amp; data.code ==<span class="fstat-no" title="function not covered" >= </span>0) {</span>
<span class="cstat-no" title="statement not covered" >                this.dataForm.roleName = data.role.roleName</span>
<span class="cstat-no" title="statement not covered" >                this.dataForm.remark = data.role.remark</span>
                var idx = data.role.menuIdList.indexOf(this.tempKey)
                if (idx !== -1) {
                  data.role.menuIdList.splice(idx, data.role.menuIdList.length - idx)
                }
                this.$refs.menuListTree.setCheckedKeys(data.role.menuIdList)
              }
            })
          }
        })<span class="fstat-no" title="function not covered" ></span>
      },<span class="cstat-no" title="statement not covered" ></span>
      // 表单提交
      dataFo<span class="cstat-no" title="statement not covered" >rmSubmit () {</span>
        this.$<span class="cstat-no" title="statement not covered" >refs['dataForm'].validate((valid) =&gt; {</span>
          if (valid) {
            this.$http({
              url: this.$http.adornUrl(`/sys/role/${!this.dataForm.id ? 'save' : 'update'}`),
              method: 'post',<span class="fstat-no" title="function not covered" ></span>
              data<span class="cstat-no" title="statement not covered" >: this.$http.adornData({</span>
                'r<span class="cstat-no" title="statement not covered" >oleId': this.dataForm.id || undef</span>ined,
                'roleName': this.dataForm.roleName,
                'remark': this.dataForm.remark,
                'menuIdList': [].concat(this.$refs.menuListTree.getCheckedKeys(), [this.tempKey], this.$refs.menuListTree.getHalfCheckedKeys())
<span class="cstat-no" title="statement not covered" >              })</span>
            }).then(({data}) =&gt; {
              if (data &amp;&amp; data.code === 0) {
                this.$message({
                  message: '操作成功',
                  type: 'success',
                  duration: 1500,
                  onClose: () =&gt; {
                    this.visible = false
                    this.$emit('refreshDataList')
                  }
                })
              } else {
                this.$message.error(data.msg)
              }
            })
          }
        })
      }
    }
  }
&lt;/script&gt;
&nbsp;</pre></td></tr>
</table></pre>
<div class='push'></div><!-- for sticky footer -->
</div><!-- /wrapper -->
<div class='footer quiet pad2 space-top1 center small'>
  Code coverage
  generated by <a href="https://istanbul.js.org/" target="_blank">istanbul</a> at Thu Sep 20 2018 10:14:21 GMT+0800 (中国标准时间)
</div>
</div>
<script src="..\..\..\..\prettify.js"></script>
<script>
window.onload = function () {
        if (typeof prettyPrint === 'function') {
            prettyPrint();
        }
};
</script>
<script src="..\..\..\..\sorter.js"></script>
</body>
</html>
